package com.sky.mapper;

import com.sky.entity.OrderDetail;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrdersDetailMapper {
    /**
     * 插入订单明细数据
     * @param ordersDetail
     */
    @Insert("insert into order_detail (order_id, dish_id, setmeal_id, dish_flavor, name, image, amount) " +
            " values (#{orderId}, #{dishId}, #{setmealId}, #{dishFlavor}, #{name}, #{image}, #{amount})")
    void insert(OrderDetail ordersDetail);

    /**
     * 根据订单号查询订单明细
     * @param orderId
     * @return
     */
    @Select("select * from order_detail where order_id = #{orderId}")
    List<OrderDetail> selectByOrderId(Long orderId);
}
